package com.atkxp.stustatusmasystem.service;

import com.atkxp.stustatusmasystem.mapper.StudentMapper;
import com.atkxp.stustatusmasystem.pojo.Course;
import com.atkxp.stustatusmasystem.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author user
 * @declaration
 * @create 2023/5/24-19:53
 */
@Service
public class StudentServiceImpl implements StudentService{

    @Autowired
    public StudentMapper studentMapper;

    @Override
    public List<Student> getAllStudents() {
        return studentMapper.getAllStudents();
    }

    @Override
    public List<Student> getAllStudentsByTid(String tid) {
        return studentMapper.getAllStudentsByTid(tid);
    }

    @Override
    public Long getStudentCount() {
        return studentMapper.getStudentCount();
    }

    @Override
    public Long getStudentCountByTid(String tid) {
        return studentMapper.getStudentCountByTid(tid);
    }

    @Override
    public Student login(String sid, String password) {
        return studentMapper.queryStuBySidAndPassword(sid, password);
    }

    @Override
    public List<Course> getAllCoursesBySidAndSyear(String sid, int syear) {
        Map msg = new HashMap<>();
        msg.put("sid", sid);
        msg.put("syear", syear);
        return studentMapper.getAllCoursesBySidAndSyear(msg);
    }

    @Override
    public int addStudent(Student student) {
        return studentMapper.addStudent(student);
    }

    @Override
    public int deleteStudentById(int id) {
        return studentMapper.deleteStudentById(id);
    }

    @Override
    public Student getStudentById(int id) {
        return studentMapper.getStudentById(id);
    }

    @Override
    public int updateStudentById(Student student) {
        return studentMapper.updateStudentById(student);
    }


}
